home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / prog_bas / tblevw.zip / WHERE.BAS < prev    next >
BASIC Source File  |  1994-04-18  |  2KB  |  70 lines

  1. ' WHERE.BAS - This module contains routines for
  2. ' locating the TrueGrid installation directory
  3. ' some file utilities
  4.  
  5.  
  6. Declare Function GetPrivateProfileString Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
  7.  
  8. Function ExtractBase (ByVal PathName As String) As String
  9.  
  10. ' Return the basename portion of a full pathname
  11.  
  12.     F$ = ExtractFile(PathName)
  13.     N% = InStr(F$, ".")
  14.  
  15.     If N% > 0 Then F$ = Left$(F$, N% - 1)
  16.  
  17.     ExtractBase = F$
  18.  
  19. End Function
  20.  
  21. Function ExtractFile (ByVal PathName As String) As String
  22.  
  23. ' Return the filename portion of a full pathname
  24.  
  25.     F$ = PathName
  26.  
  27.     Do
  28.         N% = InStr(F$, "\")
  29.         If N% > 0 Then F$ = Right$(F$, Len(F$) - N%)
  30.     Loop While N% > 0
  31.  
  32.     ExtractFile = F$
  33.  
  34. End Function
  35.  
  36. Function ExtractPath (ByVal PathName As String) As String
  37.  
  38. ' Return the directory path portion of a full pathname
  39.  
  40.     F$ = PathName
  41.  
  42.     Do
  43.         N% = InStr(F$, "\")
  44.         If N% > 0 Then F$ = Right$(F$, Len(F$) - N%)
  45.     Loop While N% > 0
  46.  
  47.     ExtractPath = Left$(PathName, Len(PathName) - Len(F$))
  48.  
  49. End Function
  50.  
  51. Function TrueGridWhere$ ()
  52.  
  53. ' Return the TrueGrid installation directory as specified in
  54. ' TRUEGRID.INI, terminated with a backslash.  If TRUEGRID.INI
  55. ' cannot be found, or if it does not contain an "InstallDirectory"
  56. ' entry, then this routine returns an empty string.
  57.  
  58.     Dim TGPath As String * 256
  59.  
  60.     Z% = GetPrivateProfileString("TrueGrid", "InstallDirectory", "", TGPath, 256, "truegrid.ini")
  61.  
  62.     If Z% = 0 Then
  63.         TrueGridWhere$ = ""
  64.     Else
  65.         TrueGridWhere$ = Left$(TGPath, Z%) + "\"
  66.     End If
  67.  
  68. End Function
  69.  
  70.